# encoding: utf-8

class GroupsSectionsController < ApplicationController

	before_filter :load_sidebar
  before_filter :require_moderator

  # GET /groups_sections/new
  # GET /groups_sections/new.xml
  def new
    @groups_section = GroupsSection.new
  end

  # GET /groups_sections/1/edit
  def edit
    @groups_section = GroupsSection.find(params[:id])
  end

  # POST /groups_sections
  # POST /groups_sections.xml
  def create
    @groups_section = GroupsSection.new(params[:groups_section])

      if @groups_section.save
        redirect_to(groups_path, :notice => 'Sekcija grupa je stvorena.') 
      else
        render :action => "new" 
      end
  end

  # PUT /groups_sections/1
  # PUT /groups_sections/1.xml
  def update
    @groups_section = GroupsSection.find(params[:id])

      if @groups_section.update_attributes(params[:groups_section])
        redirect_to(groups_path, :notice => 'Sekcija grupa je izmjenjena.') 
      else
        render :action => "edit" 
      end
  end

  # DELETE /groups_sections/1
  # DELETE /groups_sections/1.xml
  def destroy
    @groups_section = GroupsSection.find(params[:id])
    @groups_section.destroy

	redirect_to(groups_path) 
  end
end
